import cv2
import matplotlib.pyplot as plt
import numpy as np

img = cv2.imread("../images/zhifangtu.png", cv2.IMREAD_GRAYSCALE)

plt.hist(img.flatten(), bins=255, range=(0, 255), density=True)
plt.show()

# 进行普通原始直方图均衡化
img_eq = cv2.equalizeHist(img)
plt.hist(img_eq.flatten(), bins=255, range=(0, 255), density=True)
plt.show()

img_stack = np.hstack((img, img_eq))
cv2.imshow("img_stack", img_stack)
cv2.waitKey(0)